package com.mz.ozy.mvp.presenter;

import android.app.Activity;
import android.content.Context;

import com.mz.ozy.base.BasePresenterImpl;
import com.mz.ozy.bean.ArticleDetailBean;
import com.mz.ozy.constants.Constants;
import com.mz.ozy.mvp.model.ArticleModel;
import com.mz.ozy.mvp.model.DynamicsDetailModel;
import com.mz.ozy.mvp.model.FollowModel;
import com.mz.ozy.mvp.view.StrategyDetailContract;
import com.mz.ozy.net.MyObserver;
import com.mz.ozy.net.RetrofitUtils;
import com.mz.ozy.utils.JsonUtils;
import com.mz.ozy.utils.RxUtil;

import org.json.JSONObject;

import java.util.HashMap;
import java.util.Map;

import io.reactivex.Observable;
import okhttp3.ResponseBody;

/**
 * Created by administrator on 2018/12/3.
 */
public class StrategyDetailPresenter extends BasePresenterImpl<StrategyDetailContract.View> implements StrategyDetailContract.Presenter {

    private ArticleModel mArticleModel;

    public StrategyDetailPresenter() {
        mArticleModel = new ArticleModel();
    }

    public void queryArticleDetail(Context context, int wid) {
        mArticleModel.queryArticleDetail(context, wid)
                .compose(RxUtil.rxSchedulerHelper(mView.<ResponseBody>bindToLifecycle()))
                .subscribe(new MyObserver<ArticleDetailBean>(mView) {

                    @Override
                    public void onSuccesss(ArticleDetailBean bean) {
                        mView.getArticleDetail(bean);
                    }
                });
    }

    @Override
    public void followTheObject(Context context, int id, int type) {
        mArticleModel.followTheObject(context, id, type).
                compose(RxUtil.rxSchedulerHelper(mView.<ResponseBody>bindToLifecycle()))
                .subscribe(new MyObserver<JSONObject>(mView) {

                    @Override
                    public void onSuccesss(JSONObject jsonObject) {
                        mView.followSuccess(jsonObject);
                    }
                });
    }
}
